package acwing.前缀和与差分;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/5
 */
public class Prefix {

    private static final int N=100010; //数据范围

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt(); // m次询问
        int[] a = new int[N];
        int[] s = new int[N];
        for (int i = 1; i <= n; i++) { // 初始化数组
            a[i]=scanner.nextInt();
        }

        for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i]; // 前缀和的初始化

        while(m-- != 0) {
            // 输入范围
            int l=scanner.nextInt(),r=scanner.nextInt();
            System.out.println(s[r] - s[l - 1]);
        }


    }
}
